package com.genius.smsdao.teachermanage.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.genius.smsbase.Domain.BaseEntity;
import com.genius.smsdao.admin.domain.Role;
import com.genius.smsdao.coursemanage.domain.Course;

import javax.persistence.*;
import java.util.List;


/**
 * @Entity:Teacher 教师实体类
 * 对应数据库表名：teacher
 * @author：   yuanquan
 */
@Entity
@Table(name = "teacher")
public class Teacher extends BaseEntity<Long> {

    @Column
    private String number;
    @Column
    private String sex;         //性别
    @Column
    private String name;        //名字
    @Column
    private String password;    //密码
    @Column
    private String telephone;
    @Column
    private String address;

    //教师到课程一对多关系
    @JsonIgnoreProperties(value = "teacher",allowSetters = true)
    @OneToMany(mappedBy = "teacher",cascade = {CascadeType.REMOVE,CascadeType.REFRESH},fetch = FetchType.EAGER)
    private List<Course> courseList;

    //教师到部门多对一关系
    @JsonIgnoreProperties("teacherList")
    @ManyToOne(targetEntity = Department.class,fetch = FetchType.EAGER)
    @JoinColumn(name = "department_id",referencedColumnName = "id")
    private Department department;

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public List<Course> getCourseList() {
        return courseList;
    }

    public void setCourseList(List<Course> courseList) {
        this.courseList = courseList;
    }

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    @Override
    public String toString() {
        return "Teacher{" +
                "number='" + number + '\'' +
                ", sex='" + sex + '\'' +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", telephone='" + telephone + '\'' +
                ", address='" + address + '\'' +
                ", department=" + department +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", id=" + id +
                '}';
    }
}
